import {reactive, onMounted, onBeforeUnmount} from 'vue';

export default function () {
	// 实现鼠标打点的数据
	let point = reactive({
		x: 0,
		y: 0,
	});

	// 实现鼠标打点相关的方法
	const savePoint = (event) => {
		console.log(event.pageX);
		console.log(event.pageY);
		point.x = event.pageX;
		point.y = event.pageY;
	};

// 设置单击事件监听
	onMounted(() => {
		window.addEventListener('click', savePoint);
	});

// 移除单击事件监听
	onBeforeUnmount(() => {
		window.removeEventListener('click', savePoint);
	});

	return point;

}

